package com.kuang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
public class RestFulController {

    //原来的方式 localhost:8080/add?a=1&b=2
    //RestFul：localhost:8080/add/a/b
    //@RequestMapping(value = "/add/{a}/{b}",method = RequestMethod.GET)//method表示请求方式 如果请求的方式不对就会报错405
    @GetMapping("/add/{a}/{b}")
    public String RestFul(@PathVariable int a,@PathVariable int b, Model model){
        int res = a+b;
        model.addAttribute("msg","结果为1："+res);
        return "test";
    }

    @PostMapping("/add/{a}/{b}")
    public String RestFul2(@PathVariable int a,@PathVariable int b, Model model){
        int res = a+b;
        model.addAttribute("msg","结果为2："+res);
        return "test";
    }
}
